<!DOCTYPE html>
<html lang="en">
<head>
    <title>公司管理层-陪同拜访</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="Cache-Control" content="no-store, must-revalidate">
    <meta http-equiv="expires" content="Wed, 26 Feb 1997 08:21:57 GMT">
    <meta http-equiv="expires" content="-1">
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="shortcut icon" href="/dist/img/icon.png" type="image/x-icon">
    <!-- Bootstrap 3.3.6 -->
    <link rel="stylesheet" href="/dist/plugins/bootstrap/css/bootstrap.min.css">
    <!--字体-->
    <link rel="stylesheet" href="/dist/css/font-awesome.min.css">
    <!--图标-->
    <link rel="stylesheet" href="/dist/css/ionicons.min.css">
    <!--OA主样式-->
    <link rel="stylesheet" href="/dist/css/OA.min.css?t=4a6c1b54">
    <link rel="stylesheet" href="/dist/css/skins/OA-skins.min.css?t=16f1e6f3">
    <style>
        td{
            position: relative;
        }
        .tryStyle{
            width: 30px;
            height: 14px;
            font-size: 10px;
            top: 0;
            right: 0;
            position: absolute;
            border-radius: 5px;
            margin-top: 4px;
            background: red;
            color: #fff;
            margin-right: 5px;
            transform: scale(0.7);
        }
        .row {
            margin-right: -15px;
            margin-left: 0px;
        }
        .col-lg-6,.col-xs-6,.col-md-6{
            padding-left: 0;
        }
    </style>
</head>
<body>
<section class="content" id="app">
    <h1 style="text-align: center;font-size: 20px;margin-bottom:10px;margin-top: 0;"   v-cloak>{{list[0].managerName}}-陪跑-客户列表</h1>
    <div class="row">
        <table class="table text-center" id="myTable">
            <thead>
            <tr>
                <th style="width: 120px;text-align: center">大区经理</th>
                <th style="width: 120px;text-align: center">陪跑区域经理</th>
                <th style="width: 120px;text-align: center">
                    区域经理在职状态
                </th>
                <th style="width: 120px;text-align: center">
                    区域经理入职天数
                </th>
                <th style="width: 120px;text-align: center">客户电话</th>
                <th style="width: 120px;text-align: center">客户姓名</th>
                <th style="width: 120px;text-align: center">客户微信号</th>
                <th style="width: 120px;text-align: center">拜访时间</th>
            </tr>
            </thead>
            <tbody>
            <tr v-for="(item, i) in list"   v-cloak>
                <td  >{{item.managerName}}</td>
                <td style="text-align: center" >{{item.entourageName}}</td>
                <td >{{Flage2Name(item.jobState)}}</td>
                <td style="text-align: center" >{{item.dayNumber}}</td>
                <td style="text-align: center" >{{item.customerTel}}</td>
                <td style="color:#169BD5;cursor: pointer;text-align: center" @click="lookRegionList(item)">{{item.customerName?item.customerName:"-"}}</td>
                <td style="text-align: center"  >{{item.customerWechat?item.customerWechat:"-"}}</td>
                <td style="text-align: center" >{{item.arrivalsTime?formatDate(item.arrivalsTime):"-"}}</td>
            </tr>
            </tbody>
        </table>
    </div>
    <!-- /.box-body -->
</section>
<!--JQ-->
<script src="https://file.ggxqce.com/web/jquery-2.2.3.min.js"></script>
<!--插件JS-->
<script src="https://file.ggxqce.com/web/bootstrap.min.js"></script>
<!--框架已定义 JS-->
<script src="/dist/js/app_iframe.js?t=602456c3"></script>
<!--oa自定义  JS-->
<script src="/dist/js/oa.js?t=6348cbbc"></script>
<script src="https://file.ggxqce.com/web/vue.min.js"></script>
<script type="text/javascript" src="/dist/plugins/lhgdialog/lhgdialog.min.js?self=true"></script>
<script type="text/javascript" src="/dist/plugins/highcharts/highcharts.js"></script>
<script type="text/javascript">
    console.log(urlConfig);
    var app = new Vue({
        el: '#app',
        data: {
            currentUser: getCurrentUser(),
            list: [{"managerName":""}],
            userId: $.wyui.page.urlParams.userId,
            entourage:$.wyui.page.urlParams.entourage,
            dateTime:$.wyui.page.urlParams.dateTime,
            today:new Date().Format("yyyy-MM-dd"),
            time: "",
            isToday: "1"
        },
        methods: {
            Flage2Name:function (flage) {
                if(flage=="-2") return "试岗";
                if(flage == "-1") return "试用期";
                if(flage == "0") return "在职";
                if(flage == "1") return "离职";
                if(flage == "2") return "档案不全";
                if(flage == "") return "-";
            },
            //  查看下属
            lookRegionList:function (item) {
                var that = this;
                url = "/page/reportForm/interview/interviewDetail.html";
//                window.open(url + '?userId=' + item.managerId+"&dateTime="+this.dateTime+"&name="+item.managerName, "", "top=50,left=" + (window.screen.width - 10 - 1000) / 2 + ",width=1000,height=600");
                top.$.dialog({
                    content: 'url:'+url+'?id='+item.customerId+"&dateTime="+that.dateTime+"&big=true",
                    title: '拜访详情',
                    width: 300,
                    height: 500,
                    max: false,
                    min: false,
                    lock: true
                });
            },
            formatDate:function(now){
                var d=new Date(now);
                var hour=d.getHours();
                var minute=d.getMinutes();
                var second=d.getSeconds();
                if(hour<10){
                    hour="0"+hour;
                }
                if(minute<10){
                    minute="0"+minute;
                }
                if(second<10){
                    second="0"+second;
                }
                return hour+":"+minute+":"+second;
            },
            getLastEndMonth: function (beginYearMonth) {
                var strYear = parseInt(beginYearMonth.substr(0, 4), 10);
                var strMonth = parseInt(beginYearMonth.substr(4, 6), 10);
                if (strMonth - 1 == 0) {
                    strYear -= 1;
                    strMonth = 12;
                } else {
                    strMonth -= 1;
                }
                if (strMonth < 10) {
                    strMonth = "0" + strMonth;
                }
                var monthstr = strYear + "" + strMonth;
                return monthstr;
            },
            getMonths: function () {
                var that = this;
                var dateTime = new Date().Format("yyyyMM");
                for (var i = 0; i < 5; i++) {
                    dateTime = that.getLastEndMonth(dateTime);
                    that.months.push(that.insert_flg(dateTime, "-", "4"))
                }
            },
            insert_flg: function (str, flg, sn) {
                var newstr = "";
                for (var i = 0; i < str.length; i += sn) {
                    var tmp = str.substring(i, i + sn);
                    console.log(tmp)
                    newstr += tmp + flg;
                }
                newstr = newstr.substr(0, newstr.length - 1);
                return newstr;
            },
            tablesMergeCell:function(list){
                for (field in list[0]) {
                    var k = 0;
                    while (k < list.length) {
                        list[k][field + 'span'] = 1;
                        list[k][field + 'dis'] = false;
                        for (var i = k + 1; i <= list.length - 1; i++) {
                            if (list[k][field] == list[i][field] && list[k][field] != ''||list[k][field]==0&&list[i][field]==0) {
                                list[k][field + 'span']++;
                                list[k][field + 'dis'] = false;
                                list[i][field + 'span'] = 1;
                                list[i][field + 'dis'] = true;
                            } else {
                                break;
                            }
                        }
                        k = i;
                    }
                }
                return list;
            },

            getList: function () {
                var that = this;
                $.wyui.postMethod(urlConfig.report.visitCustomer.getCustomerByManage, {
                    "dateTime":that.dateTime,"userId":that.userId,"entourage":that.entourage
                } , function (data) {
                    console.log(data);
                    that.list = that.tablesMergeCell(data);
                });
            }
        },
        mounted: function () {
            //获取前5个月
            var that = this;
            that.time = new Date().Format("yyyy-MM");
            that.getList();
            $("body").delegate(".nav-tabs li a", "click", function () {
                var dateTime = $(this).text();
                if (dateTime == "本月") {
                    that.isToday = "0";
                    that.time = new Date().Format("yyyy-MM");
                } else if (dateTime == "今天") {
                    that.isToday = "1";
                } else {
                    that.isToday = "0";
                    that.time = dateTime;
                }
                that.getList();
            });
        }
    });
</script>

</body>
</html>